package com.codes.core.common;

import org.springframework.boot.system.ApplicationHome;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;

/**
 * @Description //  $
 * @Date 2020/6/29 19:43
 * @Created by peanut
 */
public class ResourceUtil {

    public static void main(String[] args) throws IOException {



//        ApplicationHome h = new ApplicationHome(ResourceUtil.class);
//        File jarF = h.getSource();
//        System.out.println(jarF.getParentFile().toString());
//
//        File directory = new File("xpyd/src/main/resources");
//        String reportPath = directory.getCanonicalPath();
//        System.out.println(reportPath);

//
//        String fileName = "classpath:/template/word";
//        Resource inputStream = new DefaultResourceLoader().getResource(fileName);//.resourceLoader(fileName);
//        String fff  =inputStream.getFile().getPath();
//        System.out.println("ffffffffff"+fff);

//        Resource resource = new ClassPathResource("/template/word");
//// 有些系统提示找不到资源，可以把上面的代码换成下面这句：
//// ClassPathResource resource = new ClassPathResource("picture/bottom.png");
//        File sourceFile =  resource.getFile();
//        String fileUrl = sourceFile.getPath();
//        String fileUrl2 = sourceFile.getAbsolutePath();
//        String fileUrl3 = sourceFile.getCanonicalPath();
//        System.out.println(fileUrl);
//        System.out.println(fileUrl2);
//        System.out.println(fileUrl3);
//
//        System.out.println("____________________________");
//
//        //            xpyd\src\main\resources\template
//        String lu = "";// ResourceUtil.class.getResource("../../template/word").getPath();
//        String ssssss =  System.getProperty("user.dir");
//        File f  =  ResourceUtils.getFile("/template");
//        String fUrl =  f.getPath();
//        System.out.println(lu);
//        System.out.println(fUrl);
//        System.out.println(ssssss);


    }


}